/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package views;

import controllers.entity.CanBo;
import controllers.entity.ChamThi;
import controllers.process.CanBoProcess;
import controllers.process.ChamThiProcess;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JOptionPane;
import java.util.Date;
import java.util.Calendar;
import javax.swing.JFrame;
import javax.swing.JPanel;
import models.Constant;
import views.JPanel.ChucNangCB;

/**
 *
 * @author HoaDuyen
 */
public class CanBoFrame extends javax.swing.JFrame {

    /**
     * Creates new form CanBoFrame
     */
    private CanBo canbo;
    private ChamThi chamthi;
    private CanBoProcess canBoProcess;
    private ChamThiProcess chamThiProcess;
    private JFrame win;
    private ChucNangCB window;
    public CanBoFrame(final JFrame win,JPanel window) {
        this.win=win;
        this.window=(ChucNangCB)window;
        initComponents();
        this.setResizable(false);
        this.setLocation(Constant.LOCATE_XPANEL, Constant.LOCATE_YPANEL);
        canBoProcess=new CanBoProcess();
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                win.setEnabled(true);
            }  
        
        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        hoten = new javax.swing.JTextField();
        gioitinh = new javax.swing.JComboBox();
        jLabel52 = new javax.swing.JLabel();
        khoavien = new javax.swing.JTextField();
        jLabel58 = new javax.swing.JLabel();
        date = new com.toedter.calendar.JDateChooser();
        jLabel56 = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        diachi = new javax.swing.JTextField();
        sdt = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        Email = new javax.swing.JLabel();
        email = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        chucvu = new javax.swing.JTextField();
        chucdanh = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel59 = new javax.swing.JLabel();
        masothue = new javax.swing.JTextField();
        sotaikhoan = new javax.swing.JTextField();
        jLabel60 = new javax.swing.JLabel();
        phucapchucvu = new javax.swing.JTextField();
        jLabel61 = new javax.swing.JLabel();
        btsave = new javax.swing.JButton();
        jLabel55 = new javax.swing.JLabel();
        jPanel23 = new javax.swing.JPanel();
        jLabel50 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        jLabel54 = new javax.swing.JLabel();
        dangvien = new javax.swing.JCheckBox();
        doanvien = new javax.swing.JCheckBox();
        congdoanvien = new javax.swing.JCheckBox();
        hesoluong = new javax.swing.JTextField();
        thanhtich = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        phucapgiangday = new javax.swing.JTextField();
        jLabel62 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Thêm Cán Bộ");

        jPanel2.setBackground(new java.awt.Color(102, 204, 255));

        jPanel9.setBackground(new java.awt.Color(102, 204, 255));

        jLabel1.setText("Họ và tên");

        jLabel3.setText("Ngày sinh");

        jLabel4.setText("Giới Tính");

        hoten.setToolTipText("");
        hoten.setName(""); // NOI18N

        gioitinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nam", "Nữ" }));
        gioitinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gioitinhActionPerformed(evt);
            }
        });

        jLabel52.setText("Khoa viện");

        jLabel58.setForeground(new java.awt.Color(255, 0, 51));

        date.setDateFormatString("dd/MM/yyy");

        jLabel56.setForeground(new java.awt.Color(255, 0, 51));
        jLabel56.setText("*");

        jLabel57.setForeground(new java.awt.Color(255, 0, 51));
        jLabel57.setText("*");

        jLabel11.setText("Địa chỉ");

        jLabel12.setText("SĐT");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel9Layout.createSequentialGroup()
                            .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel58))
                                .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, Short.MAX_VALUE)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel56, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel57, javax.swing.GroupLayout.Alignment.TRAILING))
                            .addGap(18, 18, 18))
                        .addGroup(jPanel9Layout.createSequentialGroup()
                            .addComponent(jLabel52)
                            .addGap(63, 63, 63)))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addGap(40, 40, 40)))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                            .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(hoten)
                                .addComponent(date, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE))
                            .addGap(29, 29, 29))
                        .addComponent(khoavien, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(gioitinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(diachi, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sdt, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(hoten, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel56))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jLabel57))
                    .addComponent(date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(jLabel58))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel52)
                            .addComponent(khoavien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(gioitinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(25, 25, 25)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(diachi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sdt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jPanel10.setBackground(new java.awt.Color(102, 204, 255));

        Email.setText("Email");

        email.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                emailActionPerformed(evt);
            }
        });

        jLabel6.setText("Chức vụ");

        chucvu.setName(""); // NOI18N

        chucdanh.setMaximumSize(new java.awt.Dimension(26, 20));

        jLabel5.setText("Chức danh:");

        jLabel59.setText("Mã số thuế");

        jLabel60.setText("Số tài khoản");

        jLabel61.setText("Phụ cấp chức vụ");

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(sotaikhoan, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(jLabel59)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(jPanel10Layout.createSequentialGroup()
                                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(Email)
                                            .addComponent(jLabel60))
                                        .addGap(0, 0, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
                            .addComponent(chucdanh, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
                            .addComponent(chucvu)
                            .addComponent(masothue)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel10Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabel61)
                        .addGap(18, 18, 18)
                        .addComponent(phucapchucvu, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(32, 32, 32))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Email))
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabel6))
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(chucvu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(chucdanh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel59)
                    .addComponent(masothue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel60)
                    .addComponent(sotaikhoan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(phucapchucvu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel61))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        btsave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/addemp.png"))); // NOI18N
        btsave.setText("Thêm");
        btsave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btsaveActionPerformed(evt);
            }
        });

        jLabel55.setForeground(new java.awt.Color(255, 0, 51));
        jLabel55.setText("*");

        jPanel23.setBackground(new java.awt.Color(102, 204, 255));

        jLabel50.setText("Đảng viên");

        jLabel51.setText("Đoàn viên");

        jLabel53.setText("Công Đoàn viên");

        jLabel54.setText("Hệ số lương");

        jLabel9.setText("Thành tích");

        jLabel62.setText("Phụ cấp giảng dạy");

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addComponent(jLabel53)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(congdoanvien))
                            .addGroup(jPanel23Layout.createSequentialGroup()
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel50, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel51, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(65, 65, 65)
                                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(dangvien)
                                    .addComponent(doanvien))))
                        .addGap(0, 85, Short.MAX_VALUE))
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel54)
                            .addComponent(jLabel9)
                            .addComponent(jLabel62))
                        .addGap(47, 47, 47)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(thanhtich, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(hesoluong)
                            .addComponent(phucapgiangday))))
                .addContainerGap())
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addGap(1, 1, 1)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dangvien)
                            .addComponent(jLabel50, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(7, 7, 7)
                        .addComponent(jLabel51, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(4, 4, 4))
                    .addComponent(doanvien))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel53, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(congdoanvien))
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel54)
                    .addComponent(hesoluong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(thanhtich, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel62)
                    .addComponent(phucapgiangday, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(90, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(50, 50, 50)
                        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(36, 36, 36)
                        .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(399, 399, 399)
                        .addComponent(btsave)))
                .addContainerGap(44, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(157, 157, 157)
                    .addComponent(jLabel55)
                    .addContainerGap(788, Short.MAX_VALUE)))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addComponent(btsave)
                .addGap(65, 65, 65))
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                    .addContainerGap(429, Short.MAX_VALUE)
                    .addComponent(jLabel55)
                    .addGap(29, 29, 29)))
        );

        jTabbedPane1.addTab("Thông Tin Cá Nhân", jPanel2);
        jPanel2.getAccessibleContext().setAccessibleParent(this);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        getAccessibleContext().setAccessibleParent(this);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void gioitinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gioitinhActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_gioitinhActionPerformed
    private boolean isPhoneNumber(String s){
       if ((!s.startsWith("0"))&&(!s.startsWith("+84"))) return false;
       if (s.startsWith("0")&&s.length()   > 12) return false;
       if (s.startsWith("+84")&&s.length() > 13) return false;
       if (s.length()<9)return false;
       for (int i = 1 ; i< s.length() ; i++)
           if (s.charAt(i) < '0' || s.charAt(i) > '9'){
               
               System.out.println("" + s.charAt(i));
               return false;
               
           }
        return true;

    }
    private boolean isEmail(String s){
        if (s.indexOf('@')==0 || s.indexOf('@')==s.length()-1) return false;
        if (s.indexOf('@', s.indexOf('@')+1)!=-1) return false;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)==' ')
                return false;
        }
        int i=0;
        int k=0;
        for (int j=0;j<s.length();j++){
            if (s.charAt(j)=='@')
                i++;
            if (s.charAt(j)=='.') 
                k++;
        }
        if (i==0|| i>1 ||k==0) return false;
        return true;
    }
    private void btsaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btsaveActionPerformed

        if (hoten.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            hoten.selectAll();
            hoten.requestFocus();
            return;
        }
        if (khoavien.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            khoavien.selectAll();
            khoavien.requestFocus();
            return;
        }
         if (chucvu.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            chucvu.selectAll();
            chucvu.requestFocus();
            return;
        }
          if (chucdanh.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            chucdanh.selectAll();
            chucdanh.requestFocus();
            return;
        }
           if (masothue.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            masothue.selectAll();
            masothue.requestFocus();
            return;
        }
        if (sotaikhoan.getText().length()>29){
            JOptionPane.showMessageDialog(this,"Kích thước không hợp lệ !");
            sotaikhoan.selectAll();
            sotaikhoan.requestFocus();
            return;
        }
        Date  txtDate=date.getDate();
        if (txtDate == null) {
            JOptionPane.showMessageDialog(this,"Không được bỏ trống ngày sinh !");
            return;
        }
        java.util.Date today = new java.util.Date();
        if (today.getTime() - date.getDate().getTime() < 0){
            JOptionPane.showMessageDialog(this, "Lỗi ! Ngày sinh sau ngày hôm nay !");
            return;
        }
        if ((today.getTime() - date.getDate().getTime())/31536000 >80*1000){
            JOptionPane.showMessageDialog(this, "Lỗi ! Tuổi không hợp lý (>80 tuổi) !");
            return;
        }
        if ((today.getTime() - date.getDate().getTime())/31536000 <18*1000){
            JOptionPane.showMessageDialog(this, "Lỗi ! Tuổi không hợp lý (<18 tuổi) !");
            return;
        }
        int macanbo = CanBoProcess.getCountCanBo()+1;
        
        String txtHoTen=hoten.getText();
        String txtEmail=email.getText();
        if (!txtEmail.equals(""))
        if (!isEmail(txtEmail)){
            JOptionPane.showMessageDialog(this,"Không đúng định dạng Email !");
            email.selectAll();
            email.requestFocus();
            return;
        }
        String txtKhoaVien=khoavien.getText();
        String tdiachi=diachi.getText();
        String tchucdanh=chucdanh.getText();
        String tsdt=sdt.getText();
        if (!tsdt.equals(""))
        if (!isPhoneNumber(tsdt)){
            JOptionPane.showMessageDialog(this,"Không đúng định dạng số điện thoại !");
            sdt.selectAll();
            sdt.requestFocus();
            return;
        }
        String tchucvu=chucvu.getText();
        String tgioitinh=gioitinh.getSelectedItem().toString();
        System.out.println(tgioitinh);
        boolean tdangvien=dangvien.getModel().isSelected();
        boolean tdoanvien=doanvien.getModel().isSelected();
        boolean tcongdoanvien=congdoanvien.getModel().isSelected();
        
        float tphucapcv = 0;
        if (!phucapchucvu.getText().equals(""))
        try {
                    tphucapcv = Float.parseFloat(phucapchucvu.getText());
        } catch (Exception e1) {
                    JOptionPane.showMessageDialog(this, "Phải nhập số thực vào phụ cập chức vụ !");
                    phucapchucvu.selectAll();
                    phucapchucvu.requestFocus();
                    return;
        }
        if (tphucapcv<0){
            JOptionPane.showMessageDialog(this, "Phụ cập chức vụ phải >0 !");
                    phucapchucvu.selectAll();
                    phucapchucvu.requestFocus();
                    return;
        }
        float tphucapdd = 0;
        if (!phucapgiangday.getText().equals(""))
        try {
                    tphucapdd = Float.parseFloat(phucapgiangday.getText());
        } catch (Exception e1) {
                    JOptionPane.showMessageDialog(this, "Phải nhập số thực vào phụ cấp giảng dạy !");
                    phucapgiangday.selectAll();
                    phucapgiangday.requestFocus();
                    return;
        }
        if (tphucapdd<0){
             JOptionPane.showMessageDialog(this, "Phụ cấp giảng dạy phải >0!");
                    phucapgiangday.selectAll();
                    phucapgiangday.requestFocus();
                    return;
        }
        float thesoluong = 0;
        if (!hesoluong.getText().equals(""))
        try {
                    thesoluong=Float.parseFloat(hesoluong.getText());
        } catch (Exception e1) {
                    JOptionPane.showMessageDialog(this, "Phải nhập số thực vào hệ số lương !");
                    hesoluong.selectAll();
                    hesoluong.requestFocus();
                    return;
        }
        if (thesoluong<0){
             JOptionPane.showMessageDialog(this, "Hệ số lương phải >0!");
                    hesoluong.selectAll();
                    hesoluong.requestFocus();
                    return;
        }
        
        String tmasothue=masothue.getText();
        String tsotaikhoan=sotaikhoan.getText();
        String tthanhtich=thanhtich.getText();
        CanBo cb=new CanBo(macanbo, txtHoTen,txtDate, 
                tgioitinh, tchucdanh,tchucvu, thesoluong,tphucapcv,tphucapdd,
                tmasothue,tsotaikhoan,tdiachi,tsdt,txtEmail,tdangvien,tdoanvien,tcongdoanvien,tthanhtich, "", txtKhoaVien);
        if (txtHoTen.equals("")||(txtDate == null)) {
            JOptionPane.showMessageDialog(this, "Không được để trống họ tên,ngày sinh !");
        } else {
                if (CanBoProcess.insertCanBo(cb)) {
                    JOptionPane.showMessageDialog(this, "Thêm thành công!");
                } else {
                    JOptionPane.showMessageDialog(this, "Lỗi !");
                }
        }
        window.loadTableDataThongKeNhanVien();
        this.setVisible(false);
        win.setEnabled(true);
    }//GEN-LAST:event_btsaveActionPerformed

    private void emailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_emailActionPerformed

    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Email;
    private javax.swing.JButton btsave;
    private javax.swing.JTextField chucdanh;
    private javax.swing.JTextField chucvu;
    private javax.swing.JCheckBox congdoanvien;
    private javax.swing.JCheckBox dangvien;
    private com.toedter.calendar.JDateChooser date;
    private javax.swing.JTextField diachi;
    private javax.swing.JCheckBox doanvien;
    private javax.swing.JTextField email;
    private javax.swing.JComboBox gioitinh;
    private javax.swing.JTextField hesoluong;
    private javax.swing.JTextField hoten;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel62;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField khoavien;
    private javax.swing.JTextField masothue;
    private javax.swing.JTextField phucapchucvu;
    private javax.swing.JTextField phucapgiangday;
    private javax.swing.JTextField sdt;
    private javax.swing.JTextField sotaikhoan;
    private javax.swing.JTextField thanhtich;
    // End of variables declaration//GEN-END:variables
}
